@import './common/var.css';

@keyframes van-loading {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.van-loading {
  font-size: 0;
  line-height: 0;
  z-index: 0;
  position: relative;

  &--circle {
    width: 16px;
    height: 16px;
    vertical-align: middle;
  }

  &--gradient-circle,
  &--spinner {
    width: 30px;
    height: 30px;
  }

  &__spinner {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: -1;
    display: inline-block;
    animation: van-loading 0.8s linear infinite;

    &--circle {
      border-radius: 100%;
      border: 3px solid transparent;
      box-sizing: border-box;

      &.van-loading__spinner--black {
        border-color: $gray;
        border-top-color: $gray-darker;
      }

      &.van-loading__spinner--white {
        border-color: rgba(0, 0, 0, .1);
        border-top-color: rgba(255, 255, 255, .7);
      }
    }

    &--gradient-circle {
      background-size: contain;

      &.van-loading__spinner--black {
        background-image: url('');
      }

      &.van-loading__spinner--white {
        background-image: url('');
      }
    }

    &--spinner {
      color: $gray;
      animation-timing-function: steps(12);

      i {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        position: absolute;

        &::before {
          width: 2px;
          height: 25%;
          content: ' ';
          display: block;
          margin: 0 auto;
          border-radius: 40%;
          background-color: currentColor;
        }
      }

      &.van-loading__spinner--white {
        color: #fff;
      }
    }
  }
}

@for $i from 1 to 12 {
  .van-loading__spinner--spinner i:nth-of-type($i) {
    opacity: calc(1 - (0.75 / 12) * ($i - 1));
    transform: rotate(calc($i * 30deg));
  }
}
